/**************************************************************************************************
* Title: Spring.h
* Authors: Gael Huber, Erin Mooney
* Description: Spring object that contains it's own mesh which will be manipulated internally.
**************************************************************************************************/
#ifndef __SPRING_H__
#define __SPRING_H__

#include "SmurfsMesh.h"
#include "SmurfsVector3.h"

class Spring {
public:
	Spring(void);	// Constructor
	~Spring(void);	// Destructor

	void applyForce(Vector3 appliedForce, float dt);	// Apply a force to the spring and update its mesh
	void update(Vector3 force, float mass, float dt);
	void updatePositionGlobal(Vector3 newPosition);		// Update the spring to a new position with respect to global space
	void updatePositionLocal(Vector3 newPosition);		// Update the spring to a new position with respect to local space
	Vector3 getForce(void);		// Calculate the return the force vector the spring exerts on its non-anchored end

	float springConstant;	// Spring constant
	float dampingConstant;	// Damping constant
	Vector3 velocity;
	Vector3 naturalLength;	// Natural length of the spring at equilibrium
	Vector3 currentLength;	// Current length of the spring
	Vector3 anchorGlobal;		// Global anchor point of the spring
	Vector3 anchorLocal;		// Local anchor point of the spring
	Vector3 mobileAnchor;		// Anchor point that is fixed to a moving object
	Mesh* mesh;		// Spring mesh, 0,3,6,9 need to be changed when the length of the spring is changed
};

#endif